package com.nariano.server.utils.connection;

import org.mortbay.jetty.bio.SocketConnector;
import org.springframework.beans.factory.FactoryBean;

public class SocketConnectorFactory implements FactoryBean {
	
	private int maxIdleTime;
	private int soLingerTime;
	private int port;
	private int acceptQueueSize;
	
	public void setMaxIdleTime(int maxIdleTime) {
		this.maxIdleTime = maxIdleTime;
	}

	public void setSoLingerTime(int soLingerTime) {
		this.soLingerTime = soLingerTime;
	}

	public void setPort(int port) {
		this.port = port;
	}
	
	public void setAcceptQueueSize(int acceptQueueSize) {
		this.acceptQueueSize = acceptQueueSize;
	}

	@Override
	public Object getObject() throws Exception {
		SocketConnector connection = new SocketConnector();
		connection.setMaxIdleTime(maxIdleTime);
		connection.setSoLingerTime(soLingerTime);
		connection.setPort(port);
		connection.setAcceptQueueSize(acceptQueueSize);
		return connection;
	}

	@Override
	public Class getObjectType() {
		return SocketConnector.class;
	}

	@Override
	public boolean isSingleton() {
		return false;
	}

}
